package com.powernode.teatraceability.dao.depositevidence;

import com.powernode.teatraceability.vo.ProductCertificateVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * ClassName: ProductMapper
 * Description:
 *
 * @Author: jdz
 * @Create: 2023/4/30 - 10:32
 */
@Mapper
public interface ProCerInfoMapper {
    @Insert("insert into t_procertificate(qymc, cpmc, certificateMaterial, certificateType, expire_time, create_time) values " +
            "( #{qymc}, #{cpmc},#{certificateMaterial},  #{certificateType}, #{expireTime}, #{createTime})")
    int insert(ProductCertificateVo cerInfo);
    @Update("update t_procertificate " +
            "set cpmc = #{cpmc}, certificateMaterial = #{certificateMaterial}, certificateType = #{certificateType}, " +
            "expire_time = #{expireTime}, create_time = #{createTime}" +
            "where id = #{id}")
    int update(ProductCertificateVo cerInfo);

    @Update("update t_procertificate set status=#{certificateStatus}, certificate=#{certificate} where pro_index = #{index}")
    int updateEviInfo(@Param("certificateStatus") boolean status, @Param("certificate") String certificate, @Param("index") String index);

    @Select("select * from t_procertificate where qymc= #{qymc} order by id desc")
    List<ProductCertificateVo> selectAll(String qymc);

    @Delete("delete from t_procertificate where id = #{id}")
    int delete(int id);

    @Select("select count(*) from t_procertificate where status = 1 and qymc = #{qymc}")
    int queryCnt(String qymc);

    @Select("select * from t_procertificate where cpmc like concat('%',#{cpmc},'%')")
    List<ProductCertificateVo> selectLike(String cpmc);
    @Select("select count(*) from t_procertificate where certificateType = #{cerType} and qymc= COALESCE(#{qymc}, 'default')")
    Integer countCerType(@Param("cerType") String cerTye, @Param("qymc") String qymc);

    @Select("select count(*) from t_procertificate where qymc = #{qymc}")
    Integer countInfo(String qymc);
}
